package com.cmfi.dao;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.cmfi.domain.EnergyRec;

// TODO 添加@Mapper
@Mapper
public interface EnergyRecDao {
	@Select("SELECT lastDay AS dailyUsed, DATE_FORMAT(createTime, '%Y-%m-%d') AS date FROM tbl_energyrec ORDER BY date DESC LIMIT 7")
	List<HashMap<Object,String>> get7DaysUsed();
	
	@Select("SELECT SUM(lastDay) AS monthlyTotal, DATE_FORMAT(createTime, '%Y-%m') AS `year_month` FROM tbl_energyrec GROUP BY `year_month` ORDER BY `year_month`")
	List<HashMap<Object,String>> get12MonthsUsed();
	
    @Insert("insert into tbl_energyrec (id,value,lastDay,createTime) values(#{id},#{value},#{lastDay},#{createTime})")
    public int save(EnergyRec energyRec);

//
//    @Update("update tbl_energyRec set id = #{id}, plcId = #{plcId}, nodeKey = #{nodeKey}, used = #{used}, date = #{date} where id = #{id}")
//    public int update(EnergyRec energyRec);
//    
//    @Select("select * from  tbl_energyRec where id=#{id}")
//    EnergyRec findById(Long id);
//    
//    @Select("select * from  tbl_energyRec order by id DESC limit #{start},#{itemNum}")
//	List<EnergyRec> findByPage(long start, long itemNum);
//    
//    @Select("select count(1) from tbl_energyRec")
//	  Long count();
//    
//    @Select("select * from tbl_energyRec where id = #{id}")
//    public EnergyRec getById(Long id);
//    
//    @Delete("delete from tbl_energyRec where id = #{id}")
//    public int delete(Long id);

}
